#ifndef TEST_H
#define TEST_H

#include "serialportsync.h"

#include <QObject>
#include <QDebug>

class Test : public QObject
{
    Q_OBJECT
public:

    Q_PROPERTY(QString name READ name WRITE setName RESET resetName NOTIFY nameChanged FINAL)
    Q_PROPERTY(int size READ size WRITE setSize RESET resetSize NOTIFY sizeChanged FINAL)
    explicit Test(QObject *parent = nullptr);

    void normalMethod();

    Q_INVOKABLE QString getTemperature(const QString &data);
    Q_INVOKABLE QString getWeight(const QString &data);
    Q_INVOKABLE QString calibrationgWeight();
    Q_INVOKABLE QString getPH(const QString &data);

    Q_INVOKABLE float byteToFloat(const QString &data);
    Q_INVOKABLE float byteToFloatFlip(const QString &data);
    Q_INVOKABLE void testCRC();
    Q_INVOKABLE void testFloat();

    ~Test();

    QString name() const;
    void setName(const QString &newName);
    void resetName();
    int size(){return m_size;}
    void setSize(int s){m_size=s; emit sizeChanged();}
    void resetSize(){m_size=2; emit sizeChanged();}
    void sendData(SerialPortSync& serialPort, const QString& data);

public slots:
    void slotsMethod();
signals:
    void signalTest();
    void nameChanged();
    void sizeChanged();

private:
    QString m_name {""};
    int m_size;

};

#endif // TEST_H
